#include "StdAfx.h"
#include "WeatherStation.h"

WeatherStation::WeatherStation() {}

WeatherStation::~WeatherStation(){}

void WeatherStation::RegisterObserver(std::shared_ptr<Observer> observer)
{
	m_observers.push_back(observer);
}

void WeatherStation::NotifyObserver(int temperature, int pressure, int moisture)
{
    for(int i = 0; i < static_cast<int>(m_observers.size()); ++i)
    {
        m_observers[i]->Update(temperature, pressure, moisture);
    }
}

void WeatherStation::RemoveObserver(std::shared_ptr<Observer> obsever)
{
    std::vector<std::shared_ptr<Observer>>::iterator it;
    for (it = m_observers.begin(); it != m_observers.end(); ++it)
    {
        if (obsever.get() == it->get())
        {
            m_observers.erase(it);
            break;
        }
    }
}
